
package com.genesis.yunnanji.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.genesis.yunnanji.R;
import com.genesis.yunnanji.bean.MushRoomBean;
import com.genesis.yunnanji.config.GenesisApiConfig;

import java.util.List;

public class HorizontalPagerAdapter2 extends PagerAdapter {


    private Context mContext;
    private LayoutInflater mLayoutInflater;
    private List<MushRoomBean.ResultBean.ListBean.AdvertListBean> mData;
    private boolean mIsTwoWay;

    public HorizontalPagerAdapter2(final Context context, List<MushRoomBean.ResultBean.ListBean.AdvertListBean> mData) {
        mContext = context;
        mLayoutInflater = LayoutInflater.from(context);
        this.mData = mData;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public int getItemPosition(final Object object) {
        return POSITION_NONE;
    }

    @Override
    public Object instantiateItem(final ViewGroup container, final int position) {
        final View view;

        view = mLayoutInflater.inflate(R.layout.item_coverflow, container, false);
        ImageView imageView = (ImageView) view.findViewById(R.id.img_item);
        Glide.with(mContext).load(GenesisApiConfig.PIC_HOST + mData.get(position).getAdvert_img()).into(imageView);
        container.addView(view);
        return view;
    }

    @Override
    public boolean isViewFromObject(final View view, final Object object) {
        return view.equals(object);
    }

    @Override
    public void destroyItem(final ViewGroup container, final int position, final Object object) {
        container.removeView((View) object);
    }
}